//package com.coincalf.web;
//
//import com.coincalf.dto.AgentRegisterDTO;
//import com.coincalf.entity.User;
//import com.coincalf.framework.exception.GlobalDefaultException;
//import com.coincalf.framework.geetest.GeetestLib;
//import com.coincalf.framework.http.Response;
//import com.coincalf.framework.security.UserDetails;
//import com.coincalf.framework.utils.IpUtil;
//import com.coincalf.service.UserService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.Authorization;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.core.annotation.AuthenticationPrincipal;
//import org.springframework.validation.annotation.Validated;
//import org.springframework.web.bind.annotation.*;
//import springfox.documentation.annotations.ApiIgnore;
//
//import javax.servlet.http.HttpServletRequest;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Optional;
//
///**
// * <p>
// * 用户财产记录 前端控制器
// * </p>
// *
// * @author qiang
// * @since 2018-04-17
// */
//@RestController
//@RequestMapping("/user/agent")
//@Api(value = "代理商用户 REST API", description = "代理商用户 REST API")
//@Slf4j
//public class AgentController {
//
//    @Autowired
//    private HttpServletRequest request;
//    @Autowired
//    private GeetestLib geetestLib;
//    @Autowired
//    private UserService userService;
//
//
//    /**
//     * 代理商注册
//     *
//     * @return
//     */
//    @PostMapping("/register")
//    @ApiOperation(value = "admin-agent-001 代理人注册", notes = "代理人注册", httpMethod = "POST")
//    @ApiImplicitParam(name = "agentRegister", value = "代理人注册参数", required = true, dataType = "AgentRegisterDTO")
//    public Response agentRegister(@RequestBody AgentRegisterDTO agentRegister) {
//        String ip = IpUtil.getIpAddr(request);
//        // 自定义参数,可选择添加
//        HashMap<String, String> param = new HashMap<>();
//        param.put("user_id", "qiang");      // 网站用户ID
//        param.put("client_type", "web");    // web:电脑上的浏览器；h5:手机上的浏览器，包括移动应用内完全内置的web_view；native：通过原生SDK植入APP应用的方式
//        param.put("ip_address", ip);        // 传输用户请求验证时所携带的IP
//        int gtResult = geetestLib.enhencedValidateRequest(agentRegister.getGeetest_challenge(), agentRegister.getGeetest_validate(), agentRegister.getGeetest_seccode(), param);
//        if (true) {
//            //TODO 极验验证关闭
////        if (gtResult == 1) {
//            return userService.agentRegister(agentRegister);
//        } else {
//            // 验证失败
//            throw new GlobalDefaultException(40011);
//        }
//    }
//
//    /**
//     * 查询邀请列表
//     *
//     * @param userDetails
//     * @return
//     */
//    @GetMapping(value = "/invitation")
//    @ApiOperation(value = "邀请列表", notes = "邀请列表", httpMethod = "GET", authorizations = {@Authorization(value = "Authorization")})
//    public Object invitation(@ApiIgnore @AuthenticationPrincipal UserDetails userDetails) {
//        if (!Optional.ofNullable(userDetails).isPresent()) {
//            throw new GlobalDefaultException(1000);
//        }
//        List<User> userList = userService.selectAgentInvitation(userDetails.getId());
//        return Response.ok(userList);
//    }
//}
